/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.engagesoft.cashflow.entidades;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author rchajin
 */
@Entity
@Table(name = "sucursal")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Sucursal.findAll", query = "SELECT s FROM Sucursal s"),
    @NamedQuery(name = "Sucursal.findByIdSucursal", query = "SELECT s FROM Sucursal s WHERE s.idSucursal = :idSucursal"),
    @NamedQuery(name = "Sucursal.findByNombre", query = "SELECT s FROM Sucursal s WHERE s.nombre = :nombre"),
    @NamedQuery(name = "Sucursal.findByPrefijo", query = "SELECT s FROM Sucursal s WHERE s.prefijo = :prefijo"),
    @NamedQuery(name = "Sucursal.findByIndHabilitadosucursal", query = "SELECT s FROM Sucursal s WHERE s.indHabilitadosucursal = :indHabilitadosucursal")})
public class Sucursal implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id_sucursal")
    private Integer idSucursal;
    @Size(max = 80)
    @Column(name = "nombre")
    private String nombre;
    @Size(max = 3)
    @Column(name = "prefijo")
    private String prefijo;
    @Basic(optional = false)
    @NotNull
    @Column(name = "indHabilitado_sucursal")
    private boolean indHabilitadosucursal;
    @OneToMany(mappedBy = "idSucursal")
    private Collection<TipoDocumento> tipoDocumentoCollection;
    @OneToMany(mappedBy = "idSucursal")
    private Collection<Usuario> usuarioCollection;

    public Sucursal() {
    }

    public Sucursal(Integer idSucursal) {
        this.idSucursal = idSucursal;
    }

    public Sucursal(Integer idSucursal, boolean indHabilitadosucursal) {
        this.idSucursal = idSucursal;
        this.indHabilitadosucursal = indHabilitadosucursal;
    }

    public Integer getIdSucursal() {
        return idSucursal;
    }

    public void setIdSucursal(Integer idSucursal) {
        this.idSucursal = idSucursal;
    }

    public String getNombre() {
        return nombre;
    }

    public void setNombre(String nombre) {
        this.nombre = nombre;
    }

    public String getPrefijo() {
        return prefijo;
    }

    public void setPrefijo(String prefijo) {
        this.prefijo = prefijo;
    }

    public boolean getIndHabilitadosucursal() {
        return indHabilitadosucursal;
    }

    public void setIndHabilitadosucursal(boolean indHabilitadosucursal) {
        this.indHabilitadosucursal = indHabilitadosucursal;
    }

    @XmlTransient
    public Collection<TipoDocumento> getTipoDocumentoCollection() {
        return tipoDocumentoCollection;
    }

    public void setTipoDocumentoCollection(Collection<TipoDocumento> tipoDocumentoCollection) {
        this.tipoDocumentoCollection = tipoDocumentoCollection;
    }

    @XmlTransient
    public Collection<Usuario> getUsuarioCollection() {
        return usuarioCollection;
    }

    public void setUsuarioCollection(Collection<Usuario> usuarioCollection) {
        this.usuarioCollection = usuarioCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idSucursal != null ? idSucursal.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Sucursal)) {
            return false;
        }
        Sucursal other = (Sucursal) object;
        if ((this.idSucursal == null && other.idSucursal != null) || (this.idSucursal != null && !this.idSucursal.equals(other.idSucursal))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.engagesoft.cashflow.entidades.Sucursal[ idSucursal=" + idSucursal + " ]";
    }
    
}
